package com.gxg.repository;

import com.gxg.entities.Ptitle;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PtitleRepository extends JpaRepository<Ptitle, Integer> {

    List<Ptitle> findByParentTitleAndTeacherId(String parentTitle,String teacherId);
    Ptitle save(Ptitle ptitle);
    Page<Ptitle> findAll(Pageable pageable);
    Page<Ptitle> findByTeacherId(String teacherId,Pageable pageable);
    Page<Ptitle> findByVideoClass(String videoClass,Pageable pageable);
    @Query(value = "SELECT COUNT(*) FROM Ptitle")
    int countAll();
    int countByVideoClass(String videoClass);
    int countByTeacherId(String teacherId);
    List<Ptitle> findByTeacherId(String teacherId);
}
